﻿using System.Collections.Generic;
using Xenta.Api;
using Xenta.Entities;
using Xenta.Security;
using Xenta.Utils;

namespace Xenta.Operations
{
    #region __General__

    /// <summary>
    /// Creates an item attribute.
    /// </summary>
    public class CreateOrderItemAttribute : CreateGenericAttribute<OrderItemAttributeEntity>
    {
    }

    /// <summary>
    /// Creates an item attribute.
    /// </summary>
    public class UpdateOrderItemAttribute : UpdateGenericAttribute<OrderItemAttributeEntity>
    {
    }

    /// <summary>
    /// Sets an item attribute.
    /// </summary>
    public class SetOrderItemAttribute : SetGenericAttribute<OrderItemAttributeEntity>,
        ISecuredOperation, IApiOperation
    {
        #region Properties

        /// <summary>
        /// Gets the collection of security policies.
        /// </summary>
        public IEnumerable<SecurityPolicy> SecurityPolicies
        {
            get
            {
                yield return new SecurityPolicy()
                    .IsAuthenticated()
                    .HasPermission("SALES");
            }
        }

        #endregion
    }

    /// <summary>
    /// Deletes the item attribute.
    /// </summary>
    public class DeleteOrderItemAttribute : DeleteGenericAttribute<OrderItemAttributeEntity>
    {
    }

    /// <summary>
    /// Gets the item attribute by identifier.
    /// </summary>
    public class GetOrderItemAttribute : GetGenericAttribute<OrderItemAttributeEntity>
    {
    }

    /// <summary>
    /// Gets the item attribute by the key.
    /// </summary>
    public class GetOrderItemAttributeByKey : GetGenericAttributeByKey<OrderItemAttributeEntity>
    {
    }

    /// <summary>
    /// Gets the item attribute value by key.
    /// </summary>
    public class GetOrderItemAttributeValueByKey : GetGenericAttributeValueByKey<OrderItemAttributeEntity>,
        IApiOperation
    {
    }

    #endregion

    #region __Bulk__

    /// <summary>
    /// Updates the item attributes from dictionary.
    /// </summary>
    public class BulkUpdateOrderItemAttributes : BulkUpdateGenericAttributes<OrderItemAttributeEntity>,
        IApiOperation
    {
    }

    #endregion
}
